/*
 * Copyright (c) 2008 by 1eEurope (Switzerland) AG, Thalwil
 *
 * Customer:	1eEurope (Switzerland) AG
 * Project:		BKS
 * Created:		30.09.2008, WBL
 *
*/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.WebControls;
using System.Web.UI;
using Microsoft.SharePoint;
using System.Web.UI.WebControls;

namespace By1eEurope.BKS.UserControlZone
{

    /// <summary>
    /// Parameter-Editor class for the UserControlZone FieldType
    /// </summary>
    public class UserControlZoneEditor : UserControl, IFieldEditor
    {
        protected TextBox WebSiteUrl;
        protected TextBox ListTitle;

        public void InitializeWithField(SPField field)
        {
            if (!this.IsPostBack)
            {
                UserControlZoneField uczFld = field as UserControlZoneField;
                if (uczFld != null)
                {
                    this.WebSiteUrl.Text = uczFld.WebSiteUrl;
                    this.ListTitle.Text = uczFld.ListTitle;
                }

            }
        }

        public void OnSaveChange(SPField field, bool isNew)
        {
            UserControlZoneField uczFld = field as UserControlZoneField;
            if (uczFld != null)
            {
                uczFld.ListTitle = this.ListTitle.Text;
                uczFld.WebSiteUrl = this.WebSiteUrl.Text;
            }
        }

        public bool DisplayAsNewSection
        {
            get { return true; }
        }

    }
}
